<?php
namespace app\common\only\tyyh;

class UserOpenid extends Base {
	protected $prefix = 'tyyh\\UserOpenid';

	public function get_openid($route, $uid) {
		$model = $this->getModel();
		return $this->get('get_openid_' . $route . '_' . $uid, function($model, $route, $uid) {
			$row = $model->where(['uid' => $uid])->find();
			$routeTypeEnum = loadEnum('RouteType');
			$routeOptions = $routeTypeEnum->get_options();
			if(!$routeTypeEnum->is_miniprogram_route($route)) {
				return '';
			}
			$key = $routeOptions[$route];
			return isset($row[$key]) ? $row[$key] : '';
		}, [$model, $route, $uid]);
	}
}
